﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cvk.News;

namespace BatDongSan.Modules
{
    public partial class Uct_News_Top_Img : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //GetHotNews(4);
        }
        public void GetHotNews(int ParentId)
        {
            try
            {
                List<VG_New> list = NewsBll.claNews.GetListNews(1, ParentId, 6, true, Utility.strConnect);
                if (list.Count > 0)
                {
                    hplTitle.Text = cvk.AppCode.WebUtility.CatString(list[0].Subject, 5);
                    hplTitle.ToolTip = list[0].Subject;
                    hplTitle.NavigateUrl = string.Format("/NewsDetail.aspx?idt={0}&id={1}", list[0].NewsTypeId, list[0].NewsId);
                    lblDate.Text = Convert.ToDateTime(list[0].PostDate).ToString("dd/MM/yyyy");
                    lblNote.Text = cvk.AppCode.WebUtility.CatString(list[0].Note, 30);
                    ltrImg.Text = string.Format("<img src=\"/Uploads/News/{0}\" width=\"120px\" height=\"82px\" />", list[0].ImageThumb);
                    list.RemoveAt(0);

                    rptNewsOther.DataSource = list;
                    rptNewsOther.DataBind();
                }
            }
            catch { }
        }

        protected void rptNewsOther_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            try
            {
                if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
                {
                    VG_New info = (VG_New)e.Item.DataItem;
                    HyperLink hplSubject = (HyperLink)e.Item.FindControl("hplSubject");
                    hplSubject.Text = cvk.AppCode.WebUtility.CatString(info.Subject, 10);
                    hplSubject.ToolTip = info.Subject;
                    hplSubject.NavigateUrl = string.Format("/NewsDetail.aspx?idt={0}&id={1}", info.NewsTypeId, info.NewsId);
                    //hplSubject.NavigateUrl = string.Format("http://{0}/{1}/{2}/{3}.htm", Request.Url.Authority, NewsBll.claNewsTypeDetail.GetUrlFriendly(1, info.NewsTypeId, Utility.strConnect), info.NewsId, info.SeoUrl);
                }
            }
            catch { }
        }
    }
}